const mix = require("laravel-mix");
const config = require("./webpack.config");

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.webpackConfig(config);
mix.babelConfig({
    plugins:['@babel/plugin-syntax-dynamic-import']
});

mix.setResourceRoot("public/assets")
mix.js("resources/js/app.js", "public/assets/js")
mix.sass("resources/sass/app.scss", "public/assets/css")
mix.copy('node_modules/jquery/dist/jquery.min.js', 'public/assets/lib/jquery.min.js')
mix.copy('node_modules/bootstrap/dist/js/bootstrap.min.js', 'public/assets/lib/bootstrap.min.js')

// Node: this made the chunks to a wrong path. so, disabled when using dynamic import.
// mix.extract(['vue']);

// just run in production .
// Note. if version open in dev mode, the hot result will not working
if (mix.inProduction()) {
    mix.version();
} else {
    mix.sourceMaps();
}
